<template>
  <div id="app">
    <el-container>
      <!-- 头部 -->
      <el-header class="header">
        <div class="header-content">
          <h1>
            <el-icon><Monitor /></el-icon>
            ANR 日志分析工具
          </h1>
          <div class="status">
            <el-tag :type="serviceStatus === '服务已初始化，浏览器已启动' ? 'success' : 'warning'">
              {{ serviceStatus }}
            </el-tag>
          </div>
        </div>
      </el-header>

      <!-- 主内容 -->
      <el-main class="main-content">
        <AnalysisPage />
      </el-main>
    </el-container>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import axios from 'axios'
import AnalysisPage from './views/AnalysisPage.vue'

// 响应式数据
const serviceStatus = ref('检查中...')

// 方法
const refreshStatus = async () => {
  try {
    const response = await axios.get('/api/analysis/status')
    serviceStatus.value = response.data
  } catch (error) {
    serviceStatus.value = '服务连接失败'
  }
}

// 生命周期
onMounted(() => {
  refreshStatus()
})
</script>

<style>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
  background-color: #f5f7fa;
}

#app {
  min-height: 100vh;
}

.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 0 20px;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
}

.header h1 {
  margin: 0;
  display: flex;
  align-items: center;
  font-size: 24px;
  font-weight: 600;
}

.header h1 .el-icon {
  margin-right: 10px;
  font-size: 28px;
}

.status {
  display: flex;
  align-items: center;
}

.main-content {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}
</style>